package com.study.config;

import com.study.bean.FactoryPostProcessor;
import com.study.listenter.TestApplicationListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @Description ApplicationContextInitializer接口实现类在springboot应用中启动后最先执行
 * @Author v_yangliu
 * @Date 2022/1/11 14:16
 * @Version 1.0
 **/
@Slf4j
public class ApplicationInit implements ApplicationContextInitializer<ConfigurableApplicationContext> {
    @Override
    public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
        log.info("=========我执行了initialize方法,{}===============",configurableApplicationContext.getApplicationName());
        configurableApplicationContext.addApplicationListener(new TestApplicationListener());
        configurableApplicationContext.addBeanFactoryPostProcessor(new FactoryPostProcessor());
        /*User user=configurableApplicationContext.getBean(User.class);
        log.info("user:{}",user.getName());*/
    }
}
